<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>padding方法</title>
</head>
<body>
    <h1></h1>
    <script>
        //实现一个身份证的保密显示
        const str = "12345678901234";
        let str2 = "1234";
        str2 =  str2.padStart(str.length,"x");
        let h1El = document.querySelector("h1");
        h1El.textContent = str2;
    </script>
</body>
</html>